﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Co_DataTransformationPrototype.temp
{
    public sealed class Constants
    {

        #region CrmTypes
        public sealed class CrmTypes
        {
            // Private constructor
            CrmTypes() { }

            public const string Lookup = "lookup";
            public const string PrimaryKey = "primarykey";
            public const string String = "string";
            public const string Memo = "memo";
            public const string Boolean = "boolean";
            public const string DateTime = "datetime";
            public const string Decimal = "decimal";
            public const string Float = "float";
            public const string Money = "money";
            public const string Integer = "integer";
            public const string PickList = "picklist";
            public const string StatusReason = "statusreason";
            public const string Duration = "duration";
            public const string Customer = "customer";
            public const string State = "state";
            public const string Owner = "owner";
            public const string PartyList = "partylist";
            public const string Status = "status";
            public const string UniqueIdentifier = "uniqueidentifier";
            public const string EntityNameReference = "entitynamereference";

            public const string ActivityId = "activityid";
        }
        #endregion

        #region Database
        public sealed class Database
        {
            #region Queries
            public sealed class Queries
            {
                Queries() { }

                public const string UpdateEntityRecordStatus = "UpdateEntityRecordStatus";
                public const string GetRecipientsBySourceId = "GetRecipientsBySourceId";
                public const string GetRecordsNormal = "GetRecordsNormal";

                public const string DropIfExists = "SET ANSI_NULLS ON \n SET QUOTED_IDENTIFIER ON \n SET ANSI_PADDING ON \n BEGIN \n  IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[{0}]') AND type in (N'U')) \n\r Drop Table [dbo].[{1}]";
                public const string CreateTable = " CREATE TABLE [dbo].[{0}] \n\r";

                public const string RequiredColumns = " [RowID] INT IDENTITY(1,1), [CRMGuid] NVARCHAR(255), [SourceId] NVARCHAR(255), [InsertStatus] Char(1) default 'N', [UpdateStatus] Char(1) Default 'N', [SetStateStatus] Char(1) default 'N', [ErrorDetail] NVARCHAR(MAX), ";

                public const string RequiredIndexes = " CONSTRAINT [PK_{0}] PRIMARY KEY CLUSTERED \n ( \n 	[RowId] ASC )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] ) ON [PRIMARY] \n END \n SET ANSI_PADDING OFF \n IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[{0}]') AND name = N'IX_{0}_CRMGUID') \n CREATE NONCLUSTERED INDEX [IX_{0}_CRMGUID] ON [dbo].[{0}] \n ( \n 	[CRMGuid] ASC, \n 	[InsertStatus] ASC, \n 	[UpdateStatus] ASC \n )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] \n IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[{0}]') AND name = N'IX_{0}_SourceId') \n CREATE NONCLUSTERED INDEX [IX_{0}_SourceId] ON [dbo].[{0}] \n ( \n 	[SourceId] ASC, \n 	[CRMGuid] ASC, \n 	[InsertStatus] ASC, \n 	[UpdateStatus] ASC \n )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] \n IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[{0}]') AND name = N'IX_{0}_Status') \n CREATE NONCLUSTERED INDEX [IX_{0}_Status] ON [dbo].[{0}] \n ( \n 	[InsertStatus] ASC, \n 	[UpdateStatus] ASC, \n 	[RowId] ASC \n )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] \n ";

                public const string ActivityExtraTable = " IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[{0}Recipient]') AND type in (N'U')) \n\r Drop Table [dbo].[{0}Recipient] \n\r Create table [dbo].[{0}Recipient] (ActivityId	nvarchar(100), RecipientId	uniqueidentifier, RecipientObjIdType nvarchar(100), RecipientObjSourceSystemId nvarchar(100), RecipientType nvarchar(100)) \n " + ActivityRecipientIndex;
                public const string NvarChar255 = " nvarchar(255)";
                public const string ActivityRecipientIndex = "CREATE NONCLUSTERED INDEX [IX_{0}recipient_ActivityId] ON [dbo].[{0}Recipient]([ActivityId] ASC) WITH  (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]";
            }
            #endregion

            #region Columns (Database)

            public sealed class Columns
            {
                // private constructor
                Columns() { }
                public const string CrmDataType = "CrmDataType";
                public const string LookupType = "LookupType";
                public const string Type = "Type";
                public const string ObjectType = "ObjType";
                public const string SourceSystemId = "SourceSystemId";
                public const string SourceId = "SourceId";

                //Load Sequencing

                public const string BatchId = "BatchId";
                public const string RunId = "RunId";
                public const string Status = "Status";
                public const string BatchSize = "BatchSize";
                public const string CrmServer = "CRMServer";
                public const string StartDate = "StartDate";
                public const string EndDate = "EndDate";
                public const string OrganizationName = "OrganizationName";
                public const string EntityName = "EntityName";
                public const string DisplayName = "DisplayName";
                public const string OperationType = "OperationType";
                public const string OperationTypeDisplay = "OperationTypeDisplay";

                public const string IsIntersect = "IsIntersect";
                public const string IsActivity = "IsActivity";
                public const string IsReferenceEntity = "ReferenceEntity";
                public const string Description = "Description";
                public const string Sequence = "Sequence";
                public const string InitialPendingCount = "InitialPendingCnt";
                public const string FinalPendingCount = "FinalPendingCnt";
                public const string SuccessCount = "SuccessCnt";
                public const string ErrorCount = "ErrorCnt";
                public const string RelationshipName = "RelationshipName";
                public const string InsertStatus = "InsertStatus";
                public const string UpdateStatus = "UpdateStatus";
                public const string IsModified = "IsModified";
                public const string IsGenerated = "IsGenerated";

                public const string CrmMetadataType = "CRMDatatype";
                public const string IsFK = "IsFK";
                public const string FKSourceType = "FKSourceType";
                public const string RelatedEntity = "RelatedEntity";
                public const string RelatedAttribute = "RelatedAttribute";
                public const string RelatedAttribute2 = "RelatedAttribute2";
                public const string RelatedEntity2 = "RelatedEntity2";
                public const string FKSourceType2 = "FKSourceType2";

                public const string CrmGuid = "CrmGuid";
                public const string SetStateStatus = "SetStateStatus";

                // Table creation
                public const string AttributeName = "AttributeName";
                public const string SqlDataType = "SqlDatatype";
                public const string DataLength = "DataLength";

                //Log Viewer
                public const string Phase = "Phase";
                public const string Timestamp = "Timestamp";
                public const string MachineName = "MachineName";
                public const string LogType = "LogType";
                public const string LogMessage = "LogMessage";
                public const string LogMessageDetail = "LogMessageDetail";

                public const string StateCode = "statecode";
                public const string StatusCode = "statuscode";
                public const string From = "from";

                public const string To = "to";
                public const string ObjectTypeCode = "objecttypecode";
            }
            #endregion

            #region Strings
            public sealed class Strings
            {
                Strings() { }

                public const string MetadataTableNames = "ava_Attribute,ava_Entity";
            }
            #endregion
        }
        #endregion

        #region Strings
        public sealed class Strings
        {
            // Private constructor
            Strings() { }
            public const string Comma = ", ";       // Comma should always have a space after that
            public const string SingleQuote = "'";
            public const string OpenBracket = "(";
            public const string CloseBracket = ")";
            public const string OpenSquareBracket = "[";
            public const string CloseSquareBracket = "]";
            public const string SemiComma = ";";
            public const string Colon = ":";
            public const string Batch = "Batch";
            public const string Space = " ";
            public const string RowId = "RowId";
            public const string Max = "MAX";
            public const string HyphenBullet = "- ";

            // Exception handling
            public const string Log = "LOG";
            public const string LogOnly = "LogOnly";
            public const string LogAndRethrow = "LogAndRethrow";

            public const string Id = "id";

            public const string CrmGuid2 = "crmguid2";
            public const string CrmGuid1 = "crmguid1";
            public const string Contact = "contact";
            public const string Account = "account";
            public const string SystemUser = "systemuser";
            public const string From = "from";

            public const string True = "true";
            public const string False = "false";

            public const string OwnerId = "ownerid";
            public const string Master = "Master";

            public const string Active = "Active";
            public const string Open = "Open";
            public const string Draft = "Draft";
            public const string Won = "Won";
            public const string Lost = "Lost";
            public const string Resolved = "Resolved";
            public const string Closed = "Closed";
            public const string Canceled = "Canceled";
            public const string Fulfilled = "Fulfilled";
            public const string Invoiced = "Invoiced";
            public const string OnHold = "OnHold";
            public const string Expired = "Expired";
            public const string Published = "Published";
            public const string Unapproved = "Unapproved";

            public const string NavigationTree = "trTreee";
            public const string EntityToGenerateControl = "UcEntityToGenerate";
            public const string SaveButton = "SaveButton";
            public const string ResetButton = "btnReset";
            public const string GenerateTablesButton = "btnGenerateTables";

            public const string Task = "Task";
            public const string Fax = "Fax";
            public const string Letter = "Letter";
        }
        #endregion
    }
}
